package online.foxnull2.foxmall.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import online.foxnull2.foxmall.order.entity.OrderItemEntity;
import online.foxnull2.foxmall.order.mapper.OrderItemMapper;
import online.foxnull2.foxmall.order.service.OrderItemService;
import online.foxnull2.foxmall.order.utils.PageUtils;
import online.foxnull2.foxmall.order.utils.Query;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Slf4j
@Service("orderItemService")
public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper, OrderItemEntity> implements OrderItemService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<OrderItemEntity> page = this.page(
                new Query<OrderItemEntity>().getPage(params),
                new QueryWrapper<>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<OrderItemEntity> listOrderItemByOrderSn(String orderSn) {
        List<OrderItemEntity> orderItemEntities = baseMapper.selectList(new QueryWrapper<OrderItemEntity>().eq("order_sn", orderSn));
        log.debug("listOrderItemByOrderSn -> {}", orderItemEntities);
        return orderItemEntities;
    }
}